<%@include file="/jsp/init.jspf" %>
<hunk:javascript src="${path}/js/rte/whizzywig.js"/>
<hunk:javascript src="${path}/js/app/item.js"/>
<hunk:init enableAjaxForm="true"/>
<layout:top menu="item"/>
<h1  class="pagetitle"> ${item.description}</h1>
<script>
    window.onload=whizzywig
</script>
<hunk:container>
    <hunk:validator form="itemForm">
        <hunk:form action="item?action=action" name="itemForm">
            <div class="auto">
                <hunk:panel>
                    <table class="hundred">
                        <tr>
                            <td>Category</td>
                            <td>Description</td>
                            <td>Code</td>
                            <td>Quantity</td>
                        </tr>
                        <tr>
                            <td>                               
                                <select name="categoryId">
                                    <c:forEach items="${cache.categories}" var="category">
                                        <%@include file="categoryOption.jspf"%>
                                    </c:forEach>
                                </select>
                            </td>
                            <td>
                                <hunk:text name="description" container="NULL"/>
                            </td>
                            <td>
                                <hunk:text name="code" container="NULL"/>
                            </td>
                            <td>
                                <hunk:text name="quantity" container="NULL" styleClass="readOnly" readOnly="true"/>
                            </td>                    
                        </tr>
                    </table>
                </hunk:panel>
                <hunk:panel>
                    <hunk:hidden name="id"/>
                    <hunk:submit label="Save"/>
                    <hunk:submit label="Search"/>
                    <hunk:button label="Clear" onclick="window.location='${path}/item.do?action=clear'" styleClass="button"/>
                </hunk:panel>
            </div>
        </hunk:form>
    </hunk:validator>
</hunk:container>

<display:table list="${items}" id="item" class="display_table">
    <display:column property="categarory.description" title="Category"/>
    <display:column property="description"/>
    <display:column property="code"/>
    <display:column property="quantity" />
    <display:column title="Action" class="action">
        <hunk:hasRole roles="admin,user">
            <%--<c:if test="${item.user.id == user.id}">--%>
            <a href="${path}/item.do?action=edit&id=${item.id}" class="icon_16 edit" title="Edit"></a>
            <input class="icon_16 delete" title="Delete" type="button" value="" onclick="Confirm('Do you want delete item ?',url,{'url':'${path}/item.do?action=delete&id=${item.id}','selector':$(this).parent().parent()});" />
            <%--</c:if>--%>
        </hunk:hasRole>
    </display:column>
</display:table>
<layout:bottom/>
